﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// This is to prevent the expiration of session
/// It will autumatically refresh an invisible iframe to let the server know the user's browser is still open.
/// </summary>
public partial class defibrillator : System.Web.UI.Page
{
    StatisticsBLL statsLogic = new StatisticsBLL();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            UpdateLogoutTime();
            // EVERY 30 SECONDS
            TimerDefibrillator.Interval = (30 * 1000);
            TimerDefibrillator.Enabled = true;
        }
    }

    protected void TimerDefibrillator_Tick(object sender, EventArgs e)
    {
        UpdateLogoutTime();
        return;
    }

    private void UpdateLogoutTime()
    {
        try
        {
            int StatsLoginID = Convert.ToInt32(Session["StatsLoginID"]);
            statsLogic.UpdateLogoutDateTime(DateTime.Now, StatsLoginID);
        }
        catch
        {
            return;
        }
    }
}
